package managedbean.MRP.MaterialRequirement; 

import java.io.Serializable;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean; 
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; 
import session.stateless.MRP.MaterialRequirement.WeeklyMaterialReqBeanLocal;
 
@ManagedBean(name="addMaterialRequirementManagerBean")
@RequestScoped
public class AddMaterialRequirementManagerBean implements Serializable { 
    
    @EJB
    WeeklyMaterialReqBeanLocal weeklyMaterialReqBeanLocal;
    
    private String statusMessage;

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }

    public void createMaterialRequirement(ActionEvent event) 
    { 
        Long id = (long)0;            
        try 
        { 
            id = weeklyMaterialReqBeanLocal.createWeeklyMaterialReq();
            statusMessage = "New Weekly Material Requirement Saved Successfully"; 
            
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,  "Add New Weekly Material Requirement Result: " + statusMessage + " (New Position ID is " + id + ")", "")); 
        } 
        catch(Exception ex) 
        { 
            ex.printStackTrace(); 
        } 
    }    
}
    

